
package com.oops.appquery;
import java.io.DataInputStream;
import org.json.JSONArray;
import org.json.JSONObject;

public class NewsSearch {
	
	public NewsSearch(String text)throws Exception{
		framework obj=new framework();
		@SuppressWarnings("deprecation")
		String line= (new DataInputStream(obj.gsearch("http://ajax.googleapis.com/ajax/services/search/news?v=1.0&"
			    + "q="+ text.replace(" ", "%20"))).readLine());
		getNewslinks(line);
	}
	public void getNewslinks(String line) throws Exception
    {
		System.out.println(line);
 	   JSONObject json = new JSONObject(line);
		JSONObject gson=json.getJSONObject("responseData");
		JSONArray kson=gson.getJSONArray("results");
		int size=kson.length();
		for(int i=0;i<size;i++)
		{
			JSONObject lson=kson.getJSONObject(i);
			String sample=lson.getString("unescapedUrl")	;
					
			System.out.println(sample);
	
		}
    }
}
